package com.example.app3.ui.notifications.recylerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.app3.R;

import com.example.app3.ui.notifications.recylerView.domain.RandomNumbers;
import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * @ClassName NumbersAdapter
 * @Date 2021/7/9 21:37
 * @Author 李明杰
 * @Description
 */

public class NumbersAdapter extends RecyclerView.Adapter<NumbersAdapter.ViewHolder> {
    private List<RandomNumbers> list;

    public NumbersAdapter(List<RandomNumbers> list){this.list=list;}

    static class ViewHolder extends RecyclerView.ViewHolder{
        TextView value1;
        TextView value2;

        public ViewHolder( View view) {
            super(view);
            value1=view.findViewById(R.id.textView14);

            value2=view.findViewById(R.id.textView15);

        }

    }

    @NonNull
    @NotNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.row2, parent, false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder( ViewHolder holder, int position) {

        RandomNumbers randomNumbers=list.get(position);
        holder.value1.setText(randomNumbers.getValue1()+"");
        holder.value2.setText(randomNumbers.getValue2()+"");
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
}
